Option Explicit On 
Option Strict On

Imports TreeCreeper01Interfaces

Friend Class cNeighbourhoodPlant
    Implements INeighbourhoodPlant
    Implements IComparable


    Private pPlant As IPlant
    Private pSpatialDistanceFromCenterPlant As Double
    Private pTaxonomicDistanceFromCenterPlant As Single


    Public Sub New(ByVal Plant As IPlant, ByVal SpatialDistanceFromCenterPlant As Double, ByVal TaxonomicDistanceFromCenterPlant As Single)
        pPlant = Plant
        pSpatialDistanceFromCenterPlant = SpatialDistanceFromCenterPlant
        pTaxonomicDistanceFromCenterPlant = TaxonomicDistanceFromCenterPlant
    End Sub


    Public ReadOnly Property Plant() As IPlant Implements INeighbourhoodPlant.Plant
        Get
            Return pPlant
        End Get
    End Property


    Public ReadOnly Property SpatialDistanceFromCenterPlant() As Double Implements INeighbourhoodPlant.SpatialDistanceFromCenterPlant
        Get
            Return pSpatialDistanceFromCenterPlant
        End Get
    End Property


    Public ReadOnly Property TaxonomicDistanceFromCenterPlant() As Single Implements INeighbourhoodPlant.TaxonomicDistanceFromCenterPlant
        Get
            Return pTaxonomicDistanceFromCenterPlant
        End Get
    End Property


    Public Function CompareTo(ByVal obj As Object) As Integer Implements System.IComparable.CompareTo
        Dim OtherNeighbourHoodPlant As INeighbourhoodPlant
        OtherNeighbourHoodPlant = CType(obj, INeighbourhoodPlant)
        If pSpatialDistanceFromCenterPlant < OtherNeighbourHoodPlant.SpatialDistanceFromCenterPlant Then
            Return -1
        ElseIf SpatialDistanceFromCenterPlant = OtherNeighbourHoodPlant.SpatialDistanceFromCenterPlant Then
            Return 0
        Else
            Return 1
        End If
    End Function


End Class
